<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Table</title>
    <link rel="stylesheet" href="/static/lib/layuiadmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/lib/layuiadmin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/lib/layuiadmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/lib/layuiadmin/css/table.css" />
</head>

<body>
<div class="admin-main">

    <blockquote class="layui-elem-quote">
        <a href="/admin/product/add" class="layui-btn layui-btn-small" id="add">
            <i class="layui-icon">&#xe608;</i> 添加产品
        </a>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>产品列表</legend>
        <div class="layui-field-box layui-form">
            <table class="layui-table admin-table">
                <thead>
                <tr>
                    <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary"></th>
                    <th>产品名称</th>
                    <th>所属系统分类</th>
                    <th>所属功能分类</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="content">
                <{volist name="products" id="item"}>
                <tr>
                    <td><input type="checkbox" lay-skin="primary"></td>
                    <td><{$item.name}></td>
                    <td><{if condition="(isset($productCat[$item['sys_cat']]))"}><{$productCat[$item.sys_cat]['name']}><{/if}></td>
                    <td><{if condition="(isset($productCat[$item['fun_cat']]))"}><{$productCat[$item.fun_cat]['name']}><{/if}></td>
                    <td><{$item.create_time}></td>
                    <td>
                        <a href="/admin/product/edit/id/<{$item.id}>"  data-opt="edit" class="layui-btn layui-btn-mini">编辑</a>
                        <a href="/admin/product/banner/id/<{$item.id}>"  data-opt="edit" class="layui-btn layui-btn-mini">产品轮播</a>
                        <a href="/admin/product_data/index/id/<{$item.id}>"  data-opt="edit" class="layui-btn layui-btn-mini">产品规格</a>
                        <a href="/admin/product/assoc/id/<{$item.id}>"  data-opt="edit" class="layui-btn layui-btn-mini">关联产品</a>
                        <a href="/admin/product/seo/id/<{$item.id}>"  data-opt="edit" class="layui-btn layui-btn-mini">seo</a>
                        <a href="javascript:;" data-id="<{$item.id}>" data-opt="del" class="layui-btn layui-btn-danger layui-btn-mini delete">删除</a>
                    </td>
                </tr>
                <{/volist}>
                </tbody>
            </table>
        </div>
    </fieldset>
    <div class="page"><{$products->render();}></div>

</div>

<script type="text/javascript" src="/static/lib/layuiadmin/plugins/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/lib/layuiadmin/js/'
    });

    layui.use('layer',function(){
        var layer = layui.layer;
        var $ = layui.jquery;
        $(".delete").click(function(){
            var id = $(this).data('id');
            $.ajax({
                url:'/admin/product/delete',
                type:'delete',
                data:{id:id},
                success:function(data){
                    if(data.code == 1){
                        layer.msg('<i class="layui-icon" style="font-size: 30px; color: #009688;">&#x1005;</i>'+data.msg,{},function(){location.reload();});
                    }else{
                        layer.msg('<i class="layui-icon" style="font-size: 30px; color: red;">&#x1006;</i>'+data.msg);
                    }
                }
            });

        });
    });
</script>
</body>

</html>